<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
		<meta http-equiv="Pragma" content="no-cache" />
		<meta http-equiv="Expires" content="0" />
		<link rel="stylesheet" href="../css/base.css">
		<script src="../js/jquery-1.8.3.min.js"></script>
		<script src="../js/laydate/laydate.js"></script>
		<script src="../js/public.js"></script>
		<title>发布信息</title>
		<style>
			body {
				background: #f2f2f2;
			}
			.list {
				height: .88rem;
				background: #fff;
				overflow: hidden;
				border-bottom: 1px solid #f2f2f2;
			}
			.list-fl {
				float: left;
				width: 30%;
				padding-left: .2rem;
				line-height: .88rem;
			}
			.list-mid {
				width: 60%;
				float: left;
			}
			.dates {
				border: none;
				text-align: right;
				line-height: .88rem;
				background: #fff;
				float: right;
			}
			.list-fr {
				text-align: right;
				padding-right: .2rem;
				box-sizing: border-box;
			}
			.list-fr-img {
				width: .18rem;
				margin: .28rem auto;
			}
			.div-btn {
				width: 80%;
				margin: 10px auto;
				text-align: center;
				line-height: .88rem;
				color: #fff;
				background: #fa4535;
				border-radius: .04rem;
			}
			.choose1 {
				width: .8rem;
				height: .4rem;
				margin: .24rem 0;
			}
			.alert-div {
				width: 80%;
				position: fixed;
				left: 10%;
				right: 10%;
				top: 10%;
				height: 363px;
				z-index: 101;
				display: none;
				background: #fff;
			}
			.span-list {
				background: #fff;
				color: #333;
				width: 100%;
				text-align: center;
				display: block;
				border-bottom: 1px solid #ddd;
				border-radius: .04rem;
			}
			.divlist {
				width: 100%;
				float: left;
				text-align: center;
				background: #fff;
				border-radius: .04rem;
			}
			.haha {
				width: 100%;
				text-align: center;
				border-bottom: 1px solid #ddd;
			}
			.fenlei {
				margin-top: .2rem;
				float: right;
			}
			.yikouja {
				line-height: 40px;
				border: none;
				border-bottom: 1px solid #ddd;
				text-align: right;
				font-size: 12px;
				width: 100%;
				display: none;
				padding-right: .2rem;
				box-sizing: border-box;
			}
			.f14 {
				font-size: 14px;
			}
		</style>
	</head>
	<body>
		<div id="overlay"></div>
		<div class="list">
			<div class="list-fl">
				产品名字
			</div>
			<div class="list-mid">
				<input type="text" class="dates f14" id="produceTitle" placeholder="请填写产品名字">
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				泥料
			</div>
			<div class="list-mid">
				<input type="text" class="dates f14" id="paste_materials" placeholder="请填写泥料">
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				制作者
			</div>
			<div class="list-mid">
				<input type="text" class="dates f14" id="author" placeholder="请填写制作者">
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				尺寸
			</div>
			<div class="list-mid">
				<input type="text" class="dates f14" id="measure" placeholder="请填写尺寸">
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				备注
			</div>
			<div class="list-mid">
				<input type="text" class="dates f14" id="remark" placeholder="请填写产品名字" value="如需批发或者定制请联系客服。" disabled="disabled">
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				制作工艺
			</div>
			<div class="list-mid">
				<input type="text" class="dates f14" id="technology" placeholder="请填写制作工艺">
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				产地
			</div>
			<div class="list-mid">
				<input type="text" class="dates f14" id="production_place" placeholder="请填写产品名字" value="中国·云南·建水" disabled="disabled">
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				破损/退换货问题
			</div>
			<div class="list-mid">
				<input type="text" class="dates f14" id="question" placeholder="请填写产品名字" value="签收时发现破损请拍照并且及时联系，我们会第一时间来为亲来处理。" disabled="disabled">
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				产品保障
			</div>
			<div class="list-mid">
				<input type="text" class="dates f14" id="guarantee" placeholder="请填写产品名字" value="店铺已通过“紫陶汇”官方认证，属于建水紫陶原产地商家并交付消保金。" disabled="disabled">
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">开拍时间</div>
			<!--<div class="list-mid">-->
			<!--<input type="text" class="dates" id="test4" placeholder="请选择开拍时间">-->
			<!--</div>-->
			<input class="list-mid" style="height: .88rem;line-height: .88rem;text-align: right;border: none;outline: none;" id="test4" placeholder="请选择开始时间">
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				截止时间
			</div>
			<input class="list-mid" style="height: .88rem;line-height: .88rem;text-align: right;border: none;outline: none" id="test5" placeholder="请选择截止时间">
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				分类
			</div>
			<div class="list-mid">
				<!--<input type="text" class="dates" placeholder="">-->
				<span id="fenlei" class="fenlei">请填写分类</span>
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				起拍价
			</div>
			<div class="list-mid">
				<input type="number" class="dates f14" id="qpj" placeholder="请填写起拍价">
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				加价幅度
			</div>
			<div class="list-mid">
				<input type="number" class="dates f14" id="jj_fd" placeholder="请填加价幅度">
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				商品数量
			</div>
			<div class="list-mid">
				<input type="number" class="dates f14" id="produce_con" placeholder="请填商品数量" value="1" disabled="disabled">
			</div>
			<div class="list-fr">
				<img src="../img/下一步@2x.png" class="list-fr-img">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				7天包退
			</div>
			<div class="list-fr">
				<img src="../img/选择%202@2x.png" class="choose1" on="1" onclick="chooseBy(this)">
			</div>
		</div>
		<div class="list">
			<div class="list-fl youfei" style="width: 70%;">
				包邮
			</div>
			<div class="list-fr">
				<img src="../img/选择%202@2x.png" class="choose1" on="1" onclick="chooseBs(this)">
			</div>
		</div>
		<div class="list">
			<div class="list-fl">
				一口价
			</div>
			<div class="list-fr" style="margin-top: .2rem;">
				<input class="radioin" data-on="yes" on="0" type="radio" name="sex" value="是"><span>是</span>
				<input class="radioin" on="0" type="radio" name="sex" value="否"><span>否</span>
			</div>
		</div>
		<div>
			<input class="yikouja" style="font-size: 14px;" type="number" placeholder="请填写一口价的价格">
		</div>
		<div id="alert-div" class="alert-div">
			<div style="line-height: .44rem;text-align: right;font-size: 12px;padding-right: 5px;box-sizing: border-box;" onclick="closeAlert()">
				关闭
			</div>
			<div>分类选取</div>
			<div style="height: 300px;overflow: auto;">
				<div>
					<p style="color: #fa4535;background: #fff;">一级分类</p>
					<p id="one_tab" style="overflow: hidden;"></p>
				</div>
				<div>
					<p style="color: #fa4535;background: #fff;">二级分类</p>
					<p id="one_tab_show" style="overflow: hidden"></p>
				</div>
			</div>
			<div onclick="trueObj()" style="background: #fa4535;text-align: center;font-size: 12px;height: .44rem;line-height:.44rem;color: #fff;">
				确认
			</div>
		</div>
		<div class="div-btn" onclick="truePost_befor()">保存</div>
	</body>
		<script>
			var oneobjname = '';
			var twoobjname = '';
			var firstTypeId = '';
			var secondTypeId = '';
			var seven_return = 1; //支持7天无理由退还
			var mail = 1;
			var isYikoujia = 1;
			var keywords = sessionStorage.keywords;
			var imgs = GetQueryString("imgs");
			var zhengshu = GetQueryString("zsurl");
			//      console.log('打印上个页面传输的sessionStorage中的产品描述：');
			//      console.log(keywords);
			$(function() {
				getFl(); //获取分类
				$(".radioin").click(function() { //是否一口价
					$(".radioin").attr("on", "0");
					$(this).attr("on", "1");
					if($(this).val() == "是") {
						isYikoujia = 1;
						$(".yikouja").show();
					} else {
						isYikoujia = 2;
						$(".yikouja").hide();
					}
				})
			});

			/**
			 * 绑定时间
			 * **/
			laydate.render({
				elem: '#test5',
				type: 'datetime',
				format: 'yyyy-MM-dd HH:mm:ss',
				
			});
			laydate.render({
				elem: '#test4',
				type: 'datetime',
				format: 'yyyy-MM-dd HH:mm:ss',
			});
			function closeAlert() {
				/**
				 * 关闭弹层
				 * **/
				hideOverlay();
				$(".span-list").css({
					background: "#fff",
					color: "#333"
				});
				$(".haha").css({
					background: "#fff",
					color: "#333"
				});
				firstTypeId = '';
				secondTypeId = '';
				$("#alert-div").hide();
			}

			function chooseBy(obj) {
				var $on = $(obj).attr("on");
				if($on == 1) {
					$(obj).attr("src", "../img/选择%201@2x.png");
					$(obj).attr("on", "0");
					seven_return = 0;
				} else {
					$(obj).attr("src", "../img/选择%202@2x.png");
					$(obj).attr("on", "1");
					seven_return = 1;
				}
			}

			function chooseBs(obj) {
				var $on = $(obj).attr("on");
				if($on == 1) {
					$(obj).attr("src", "../img/选择%201@2x.png");
					$(obj).attr("on", "0");
					mail = 0; //不包邮
					alert('请在产品价格中加入您的邮费');
					$('.youfei').html('包邮     <span style="color:red;margin-left: 0.2rem;">(请在产品价格中加入您的邮费)</span>');
				} else {
					$(obj).attr("src", "../img/选择%202@2x.png");
					$(obj).attr("on", "1");
					mail = 1; //包邮
					$('.youfei').html('包邮');
				}
			}

			function getFl() { //获取分类
				$.ajax({
					url: base_url + "ZITAOHUI/allProduceType",
					type: "post",
					success: function(data) {
						//console.log(data);
						if(data.code == 1) {
							var _d = data.extend.list;
							$.each(_d, function(k, v) {
								$("#one_tab").append('<span class="span-list" data-index="' + k + '" data-id="' + v.firstTypeId + '" onclick="showSmallobj(this)">' + v.firstTypeDiscribe + '</span>');
								if(k > 0) {
									$("#one_tab_show").append('<div class="divlist" style="display: none;"></div>');
								} else {
									$("#one_tab_show").append('<div class="divlist"></div>');
								}
								$.each(v.pst, function(ks, vs) {
									$(".divlist:last").append('<div class="haha" data-firstid="' + vs.firstTypeId + '" data-id="' + vs.secondTypeId + '" onclick="twoobj(this)">' + vs.secondTypeDiscibe + '</div>')
								})
							})
						}

					},
					error: function(erroe) {

					}
				})
			}

			function showSmallobj(obj) { //一级分类点击事件
				var _i = $(obj).attr("data-index");
				var _id = $(obj).attr("data-id");
				$(".span-list").css({
					background: "#fff",
					color: "#333"
				});
				$(".span-list").eq(_i).css({
					background: "#fff",
					color: "red"
				});
				$(".span-list").eq(_i).attr("on", "1");
				firstTypeId = _id;
				oneobjname = $(".span-list").eq(_i).text();
				$(".divlist").hide();
				$(".divlist").eq(_i).show();
			}

			function twoobj(obj) { //二级分类点击事件
				if(isNull(firstTypeId)) {
					alert("请先选择一级分类");
					return false;
				}
				var _id = $(obj).attr("data-id");
				$(".haha").css({
					background: "#fff",
					color: "#333"
				});
				$(obj).css({
					background: "#fff",
					color: "red"
				});
				$(obj).attr("ons", "2");
				secondTypeId = _id;
				//console.log("二级id="+_id);
				twoobjname = $(obj).text();

			}

			function trueObj() {
				if(isNull(oneobjname)) {
					alert("请选择一级分类");
					return false;
				}
				if(isNull(twoobjname)) {
					alert("请选择二级分类");
					return false;
				}
				hideOverlay();
				$("#fenlei").text(oneobjname + "," + twoobjname);
				$("#alert-div").hide();
			}
			$(function() {
				$("#fenlei").click(function() {
					showOverlay();
					$("#alert-div").show();
				})

			});

			function truePost_befor() {
				var produceTitle = $('#produceTitle').val();
				var test4 = $("#test4").val();
				var test5 = $("#test5").val();
				var fenlei = $("#fenlei").text() == '请填写分类' ? false : true;
				var qpj = $("#qpj").val();
				var jj_fd = $("#jj_fd").val();
				var produce_con = $("#produce_con").val();
				var paste_materials = $("#paste_materials").val();
				var author = $("#author").val();
				var measure = $("#measure").val();
				var remark = $("#remark").val();
				var production_place = $("#production_place").val();
				var question = $("#question").val();
				var guarantee = $("#guarantee").val();
				var technology = $("#technology").val();
				if(produceTitle && test4 && test5 && fenlei && qpj && jj_fd && produce_con&&paste_materials
				&& author && measure && remark && production_place && question && guarantee && technology) {
					truePost();
				} else {
					console.log('错误');
					alert('您有信息未填写完整');
					$('input').each(function(k){
						if($(this).val()==''){
							$('input').eq(k).focus();
						}
					})
				}
			}

			function truePost() {
				var yiprice = $(".yikouja").val();
				if(isYikoujia == 1) {
					if(isNull($(".yikouja").val())) {
						alert("请填写一口价");
						return false;
					}
				}
				if(isYikoujia == 2) {
					yiprice = 0;
				}
				/*      	var simgs = '';
				            if(isNull(zhengshu)){
				                simgs = imgs;
				            }else{
				                simgs = imgs +","+zhengshu;
				            }*/
				/*          alert();
				            alert(new Date($("#test4").val()));
				            alert(sTime+","+ eTime);*/
				var sTime = ($("#test5").val()).replace(/-/g, '/');
				var eTime = ($("#test4").val()).replace(/-/g, '/');
				//console.log(sTime+'转换之后的：'+new Date(sTime));
				var newurls = '';
				if(isNull(GetQueryString('ids'))) {
					newurls = "ZITAOHUI/saveAuctionSet"
				} else {
					newurls = "ZITAOHUI/updateAuctionSet?auctionId=" + GetQueryString('ids') + "&produceId=" + GetQueryString('pids');
				}

				$.ajax({
					type: 'POST',
					url: base_url + newurls,
					data: {
						auctionDeadline: new Date(sTime),
						auctionTime: new Date(eTime),
						startingPrice: $("#qpj").val(),
						produceAuctionNumber: $("#jj_fd").val(),
						sevenReturn: seven_return,
						mail: mail,
						produceFirstType: firstTypeId, //产品大类
						produceSecondType: secondTypeId, //产品小类
						produceMoney: yiprice, //如果没设置一口价就不用传
						produceDescribe: keywords, //产品描述，
						onlyStoreId: sessionStorage.getItem("s_id"), //店铺id,
						produceFixedPrice: isYikoujia,
						images: imgs,
						appraisal: zhengshu,
						value: "1",
						produceTitle: $("#produceTitle").val(),//产品标题
						produceCon: $('#produce_con').val(),//产品数量
						paste_materials:$("#paste_materials").val(),//泥料
						author:$("#author").val(),//作者
						measure:$("#measure").val(),//尺寸
						remark:$("#remark").val(),//备注
						production_place:$("#production_place").val(),//产地
						question:$("#question").val(),//退换货问题
						guarantee:$("#guarantee").val(),//产品保障
						technology:$("#technology").val()//工艺
					},
					//dataType:"json",
					beforeSend:function(){
						$('.div-btn').removeAttr('onclick');
					},
					success: function(data) {
						$('.div-btn').attr('onclick','truePost_befor()');
						if(data.code == 1) {
							alert("保存成功");
							window.location.replace("./Lot-management.html");
						} else {
							alert("保存失败");
						}
					},
					error: function(error) {
						alert("网络请求超时");
						//console.log(error);
					}
				})
			}
		</script>
	
</html>